package com.vcc.core.derive.converter.wallet;

import cn.idev.excel.converters.Converter;
import cn.idev.excel.enums.CellDataTypeEnum;
import cn.idev.excel.metadata.GlobalConfiguration;
import cn.idev.excel.metadata.data.ReadCellData;
import cn.idev.excel.metadata.data.WriteCellData;
import cn.idev.excel.metadata.property.ExcelContentProperty;

/**
 * 明细事件转换器
 */
public class UseFlagConverter implements Converter<Integer> {

    private static String useFlagToString(Integer useFlag) {

        //  { label: '开卡手续费', value: 0 },
        //  { label: '卡充值', value: 1 },
        //  { label: '卡转出', value: 2 },
        //  { label: '账户充值', value: 3 },
        //  { label: '账户提现', value: 4 },
        //  { label: '销卡转入', value: 5 },
        //  { label: '卡充值手续费', value: 6 },
        //  { label: '账户调账', value: 16 },
        //  { label: '卡调账', value: 17 },
        //  { label: '划拨转入', value: 21 },
        //  { label: '划拨转出', value: 22 },
        //  { label: '授权手续费', value: 23 },
        //  { label: '小金额手续费', value: 24 },
        //  { label: '失败手续费', value: 25 },
        //  { label: '撤销手续费', value: 26 },
        //  { label: '退款手续费', value: 27 },
        //  { label: '跨境手续费', value: 28 }
        return switch (useFlag) {
            case 0 -> "开卡手续费";
            case 1 -> "卡充值";
            case 2 -> "卡转出";
            case 3 -> "账户充值";
            case 4 -> "账户提现";
            case 5 -> "销卡转入";
            case 6 -> "卡充值手续费";
            case 16 -> "账户调账";
            case 17 -> "卡调账";
            case 21 -> "划拨转入";
            case 22 -> "划拨转出";
            case 23 -> "授权手续费";
            case 24 -> "小金额手续费";
            case 25 -> "失败手续费";
            case 26 -> "撤销手续费";
            case 27 -> "退款手续费";
            case 28 -> "跨境手续费";
            default -> "未知类型";
        };
    }

    @Override
    public Class<Integer> supportJavaTypeKey() {
        return Integer.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }


    @Override
    public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        return null;
    }


    @Override
    public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        return new WriteCellData<>(useFlagToString(value));
    }
}